<template>
  <div>

    <el-row>
      <el-col :span="24">
        <el-form :inline="true">
          <el-form-item label=" 管理员名称：">
            <el-input v-model="param.adminName" placeholder="请输入管理员名称" @change="findHistoryByCondition" v-if="admin.adminRoleId==1"></el-input>
          </el-form-item>
          <el-form-item label=" 操作方法名：">
            <el-input v-model="param.methodName" placeholder="请输入操作方法名" @change="findHistoryByCondition"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

    <el-row style="margin-top: 20px;">
      <el-col :span="18" :offset="3">
        <el-table :data="adminHistoryList" style="width: 100%">
          <el-table-column prop="adminName" label="管理员名称" width="200px" align="center" label-align="center">
          </el-table-column>
          <el-table-column prop="adminRoleName" label="权限名称" width="100" align="center" label-align="center">
          </el-table-column>
          <el-table-column prop="methodName" label="操作功能" width="400" align="center" label-align="center">
          </el-table-column>
          <el-table-column prop="historyTime" label="操作时间" width="180" align="center" label-align="center">
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>

<div class="block">
<!--            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="param.pageNum" :page-sizes="[ 3, 4, 5]" :page-size="param.pageSize"
              layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
          </div> -->
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :current-page="param.pageNum" :page-sizes="[ 8, 11,14]" :page-size="param.pageSize"
            layout="total, sizes, prev, pager, next, jumper" :total="total">
          </el-pagination>
          </div>
  </div>

</template>

<script>
  export default {
    name: "AdminHistory",
    data() {
      return {
        adminHistoryList: [], //操作历史集合
        headers: {},
        admin: {}, //管理员信息
        param:{
          adminName: null, //管理员名称
          methodName: null, //操作方法名
          pageSize: 8,
          pageNum: 1
        },
        total:0
      }

    },

    methods: {
 //查个人信息
      loadAdmin() {
        this.$http.get("/person/adminInfo/myAdminInfo.api").then(resp => {
          if (resp.data.code == 200) {
            this.admin = resp.data.data
          }
        })
      },
      //查询所有操作历史
      loadAllHistory() {
        this.$http.post("/person/adminHistory/adminHistoryList.api", this.param).then(resp => {
          if(resp.data.code=200){
            this.adminHistoryList = resp.data.data.records
          this.total=resp.data.data.total
          }else{
            this.$message({
              message: data.msg,
              type: 'error'
            });
          }

        })
      },
      //搜索操作历史
      findHistoryByCondition() {
        this.loadAllHistory();
      },
      SuccessTip(data) { //成功
        if (data.code === 200) {
          // 如果code为200，则弹出绿色的提示框
          this.$message({
            message: data.msg,
            type: 'success'
          });
        }
      },
      ErrorTip(data) { //失败
        if (data.code !== 200) {
          // 如果code为200，则弹出绿色的提示框
          this.$message({
            message: data.msg,
            type: 'error'
          });
        }
      },
    handleSizeChange(val) {
      this.param.pageSize = val
      this.loadAllHistory()
    },
    handleCurrentChange(val) {
      this.param.pageNum = val
      this.loadAllHistory()
    },
    },
    created() {
      this.loadAllHistory();
      this.loadAdmin();
      this.headers["token"] = localStorage.getItem("token");
    }
  }
</script>

<style>
</style>
